<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #div1{
            width: 200px;
            height: 400px;
            background: skyblue;
            position: absolute;
            left: -200px;
        }
        span{
            display: inline-block;
            width: 20px;
            height: 100px;
            line-height:20px;
            position: absolute;
            right: -20px;
            top:100px;
            background: red;
        }
    </style>
</head>
<body>
  <div id="div1">
      <span>分享到</span>
  </div>

  <script>
      var oDiv = document.getElementById('div1');
      var oSpan = document.getElementsByTagName('span')[0];
      var timer = null;
      var speed = 0;

      oDiv.onmouseover = function () {
          clearInterval(timer);

         timer =  setInterval(function () {

              if(oDiv.offsetLeft==0){
                  clearInterval(timer);
              }
             else {
                  oDiv.style.left = oDiv.offsetLeft+10+'px';
              }

          },30)
      };
      oDiv.onmouseout = function () {
          clearInterval(timer);
          timer =  setInterval(function () {

              if(oDiv.offsetLeft == -200){
                  clearInterval(timer);

              }
              else {
                  oDiv.style.left = oDiv.offsetLeft-10+'px';
              }


          },30)
      }




  </script>


</body>
</html>